<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //统计出现最多字符和次数
        var str = 'abcdefabsdsd';
        var obj = {};
        for(var i = 0; i < str.length; i++){
            var chars = str.charAt(i);
            if(obj[chars]){
                obj[chars]++;
            }else{
                obj[chars] = 1;
            }
        }
        console.log(obj);

        var max = 0;
        var ch = '';
        for(var k in obj){
            if(obj[k] > max){
                max = obj[k];
                ch = k;
            }
        }
        console.log('字符串中出现最多的字符为'+ch+'，出现次数为'+max);
    </script>
</head>
<body>
    
</body>
</html>